package com.aruba.canvasapplication;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Path;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.view.View;

public class PathFillView extends View {
    private Paint mPaint = new Paint();

    public PathFillView(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
        mPaint.setColor(Color.RED);
        mPaint.setStyle(Paint.Style.FILL_AND_STROKE);
    }

    @Override
    protected void onDraw(Canvas canvas) {
        Path path = new Path();
        path.offset(100, 100);
        path.addCircle(200, 200, 100, Path.Direction.CW);
        path.addCircle(300, 300, 100, Path.Direction.CW);
        // WINDING 模式 --- 取Path所有所在的区域 -- 默认的模式
        // EVEN_ODD 模式 --- 取Path所在不相交的区域
        // INVERSE_WINDING 模式 -- 取path所有未占的区域
        // INVERSE_EVEN_ODD 模式 --- 取path所有未占和相交的区域
        path.setFillType(Path.FillType.WINDING);

        canvas.drawPath(path, mPaint);
    }
}
